package com.bdqn.sys.service.impl;

import com.bdqn.sys.entity.Permission;
import com.bdqn.sys.dao.PermissionMapper;
import com.bdqn.sys.service.PermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author KazuGin
 * @since 2020-04-26
 */
@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements PermissionService {

    @Resource
    private  PermissionMapper permissionMapper;

    @Override
    public boolean removeById(Serializable id) {
        //根据菜单编号删除角色菜单权限的关系数据(sys_role_permission) 意思是如果删除菜单中某一个菜单栏权限，相对角色中拥有这个菜单权限也要一起删除，毕竟他们是绑在一起的
        permissionMapper.deleteRolePermissionByPid(id);
        return super.removeById(id);
    }

    @Override
    public List<Integer> findPermissionByRoleId(Integer roleId) throws Exception {
        return permissionMapper.findPermissionByRoleId(roleId);
    }
}
